

#ifndef REPLACEMENTPOLICY_H
#define REPLACEMENTPOLICY_H

#include <stdint.h>
#include <string>
#include <stdlib.h>
#include <pin.H>

using namespace std;

//typedef uint32_t UINT32;
//typedef uint64_t UINT64;
//typedef uint8_t UINT8;
//typedef uint16_t UINT16;

/*
 This is the generic class for replacment policy. The various replacement policies will derive from this class.
 */
class ReplacementPolicy {
    
public:
    
    ReplacementPolicy();
    virtual void blockUsed(UINT64 set, int pos);
    virtual int chooseEvictee(UINT64 set);
    
};
//Least Recently Used

class LRU: public ReplacementPolicy{
    
public:
    
    explicit LRU (UINT64 sets, int assoc);
    
    //function called for all replacement choices
    virtual int chooseEvictee(UINT64 set); 
    
    //function to determine least recently used;
    virtual void blockUsed(UINT64 set, int pos);
    
private:
    

    int shift;
    UINT8* lruArray;
    int assoc;
    UINT64 sets;
    
    
};

/*
  Round Robin replacement policy
 */

class RoundRobin : public ReplacementPolicy {
    
    
public:
    
    explicit RoundRobin(UINT64 sets, int assoc);	
    
    //function called for all replacement choices
    
    virtual int chooseEvictee(UINT64 set);  
    
       
    
private:
    
    int shift;
    int assoc;
    UINT16 assocMask;
    UINT16* rrArray;
    
};




#endif
